package com.lxh.lxhcrm.controller.aftersale;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lxh.lxhcrm.model.pojos.Complaint;
import com.lxh.lxhcrm.model.service.AfterSaleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 开发团队 ：lxh
 * 开发人员 ：李兴洋
 * 开发时间 ：2020年1月9日18:57:37
 * 类的名称 ：ComplaintController
 * 类的描述 ：售后模块中的客户投诉
 */
@RestController
@RequestMapping("/after-sale/complaint")
public class ComplaintController {
    @Autowired
    AfterSaleService afterSaleService;

    //所有投诉
    @RequestMapping("/complaint-list")
    public Map<String,Object> knowledgesList(Integer page , Integer size , String search , String kcName ){
        Page<Object> obj = PageHelper.startPage(page, size);
        List<Complaint> comList = afterSaleService.findAllComplaint(search,kcName);

        Map<String,Object> comMap = new HashMap<>();
        comMap.put("total",obj.getTotal());
        comMap.put("rows",comList);

//        System.out.println(search);System.out.println(kcName);System.out.println(page);System.out.println(size);
        return comMap;
    }

    //新增投诉
    @RequestMapping("/add-complaint")
    @ResponseBody
    public void addComplaint(@RequestBody Complaint complaint){
        afterSaleService.addComplaint(complaint);
    }

    //删除投诉
    @RequestMapping("/delete-complaint")
    @ResponseBody
    public void deleteComplaint(Integer cNo){
        afterSaleService.deleteComplaint(cNo);
    }

    //审批
    @RequestMapping("/complaintCheck")
    @ResponseBody
    public void ComplaintCheck(Integer complaintId){
        afterSaleService.complaintCheck(complaintId);
    }

}
